<template>
	<view class="city">
		<t-index-address @select="select"></t-index-address>
	</view>
</template>

<script>
	import moment from 'moment'
	export default {
		data() {
			return {

			}
		},
		onLoad() {

		},
		methods: {
			// 选中事件
			select(data) {
				console.log(data)
				uni.request({
					url: "https://geoapi.qweather.com/v2/city/lookup",
					data: {
						location: data.name,
						adm: data.province,
						key: this.$store.state.key
					},
					method: "get",
					success: (res) => {
						this.$store.commit("citys", res.data.location[0]);
						// console.log(this.$store.state.city)
						// console.log(2222222)
						// this.city = res.data.location[0]
						// this.tianqi()
						// this.shi()
						// this.xiaoshi()

						var pages = getCurrentPages();
						var prePage = pages[pages.length - 2] //上一个页面
						console.log(prePage.$vm.upDate())
						//调用上一页拉取数据的方法
						prePage.$vm.upDate()
						uni.navigateBack({
							delta: 1
						})
					},
				});
			}
		}
	}
</script>

<style scoped>

</style>
